package org.emet.entity.biz;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.emet.dao.VehicleDao;
import org.emet.help.CGResource;
import org.emet.jee.console.entity.BaseEntity;
import org.emet.jee.core.utils.spring.SpringContextHolder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "T_REFUEL_HIST")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class RefuelHist extends BaseEntity {
	private Long vehicleId;
	private String lpn;

	@CGResource("油单价")
	private BigDecimal fuelUnitPrice;
	private String fuelType;
	@CGResource("单位")
	private String unit;
	@CGResource("数量")
	private Integer quantity;
	private BigDecimal totalCharge;
	@CGResource("日期")
	private Date date;
	@CGResource("加油站")
	private String fillingStation;
	@CGResource("备注")
	private String remark;
	private Boolean paied = false;

	public Boolean isPaied() {
		return paied;
	}

	public void setPaied(Boolean paied) {
		this.paied = paied;
	}

	@Transient
	public Vehicle getVehicle() {
		VehicleDao dao = SpringContextHolder.getBean("vehicleDao");
		return dao.get(vehicleId);
	}

	public String getFuelType() {
		return fuelType;
	}

	public void setFuelType(String fuelType) {
		this.fuelType = fuelType;
	}

	public String getLpn() {
		return lpn;
	}

	public void setLpn(String lpn) {
		this.lpn = lpn;
	}

	public BigDecimal getTotalCharge() {
		return totalCharge;
	}

	public void setTotalCharge(BigDecimal totalCharge) {
		this.totalCharge = totalCharge;
	}

	public Long getVehicleId() {
		return vehicleId;
	}

	public void setVehicleId(Long vehicleId) {
		this.vehicleId = vehicleId;
	}

	public BigDecimal getFuelUnitPrice() {
		return fuelUnitPrice;
	}

	public void setFuelUnitPrice(BigDecimal fuelUnitPrice) {
		this.fuelUnitPrice = fuelUnitPrice;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getFillingStation() {
		return fillingStation;
	}

	public void setFillingStation(String fillingStation) {
		this.fillingStation = fillingStation;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
